gulp.task(ꞌstylesꞌ)   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 34

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 34
rs 8.8571
cc 1
nc 1
nop 1

1 Function

Rating   Name   Duplication   Size   Complexity  
A ��) 0 4 1
1
'use strict';
2
3
// Boilerplate & Setup
4
/*-------------------------------------------------------------------------------------------------*/
5
6
var gulp = require('gulp');
7
8
// load plugins from package.json file
9
var $ = require('gulp-load-plugins')();
10
    $.del = require('del');
11
    $.runSequence = require('run-sequence');
12
13
// Make 'build' the default task
14
gulp.task('default', function() {
15
   gulp.start('build');
16
});
17
18
// Notify when build is complete
19
gulp.task('notify:buildComplete', function(callback) {
20
   $.notify().write("Build Complete");
21
   callback();
22
});
23
24
// Empty 'stage' directory so we can start fresh
25
gulp.task('clean:stage', function(callback) {
26
   $.del([
27
      'stage/**/*',
28
  ], callback);
29
});
30
31
32
// Main Tasks
33
/*-------------------------------------------------------------------------------------------------*/
34
35
// build - The main task that runs all subtasks
36
gulp.task('build', function(callback) {
37
   $.runSequence(
38
      'clean:stage',
39
      ['styles', 'scripts'],
40
      ['copy-assets'],
41
      ['minify-css', 'minify-js'],
42
      'notify:buildComplete',
43
      callback
44
   );
45
});
46
47
// Subtasks
48
/*-------------------------------------------------------------------------------------------------*/
49
50
51
// Compile SASS
52
gulp.task('styles', function(callback) {
53
   return gulp.src('styles/**/*.scss')
54
      .pipe($.order([
55
          "styles.css",
56
          "**/*.scss"
57
      ]))
58
      // Load existing internal sourcemap
59
      .pipe($.sourcemaps.init())
60
      // generate CSS from SASS
61
      .pipe($.sass())
62
      // Catch any errors and prevent them from crashing gulp
63
      .on('error', function (error) {
64
         $.notify().write(error);
65
         this.emit('end');
66
      })
67
      // autoprefix CSS using bootstrap standards
68
      .pipe($.autoprefixer({
69
         browsers: [
70
            "Android 2.3",
71
            "Android >= 4",
72
            "Chrome >= 20",
73
            "Firefox >= 24",
74
            "Explorer >= 8",
75
            "iOS >= 6",
76
            "Opera >= 12",
77
            "Safari >= 6"
78
         ],
79
         remove: false
80
      }))
81
      // Write final .map file
82
      .pipe($.sourcemaps.write())
83
      // move files to stage
84
      .pipe(gulp.dest('stage/styles'), callback);
85
});
86
87
// Javascript
88
gulp.task('scripts', function(callback) {
89
   return gulp.src('scripts/**/*.js')
90
      // copy scripts to stage
91
      .pipe(gulp.dest('stage/scripts'), callback);
92
});
93
94
// copy node module assets locally
95
gulp.task('copy-assets', function(callback) {
96
   return gulp.src([
97
            'node_modules/jquery/dist/jquery.js',
98
            'node_modules/bootstrap-sass/assets/javascripts/bootstrap.js',
99
            'node_modules/bootstrap-sass/assets/javascripts/bootstrap/carousel.js',
100
        ])
101
      .pipe(gulp.dest('stage/scripts/vendor'), callback);
102
});
103
104
// Minify CSS and put it in the public dir
105
gulp.task('minify-css', function() {
106
  return gulp.src('stage/styles/**/*.css')
107
     .pipe($.cleanCss({
108
        processImport: false
109
     }))
110
     .pipe($.rename({
111
        basename: 'styles',
112
        suffix: '.min',
113
        extname: '.css'
114
     }))
115
    .pipe(gulp.dest('../../../public/default/themes/bootstrap/css'));
116
});
117
118
// minify JS and put in the public dir
119
gulp.task('minify-js', function () {
120
121
   return gulp.src(['stage/scripts/**/*.js'])
122
      .pipe($.order([
123
        "vendor/jquery.js",
124
        "vendor/bootstrap.js",
125
        "vendor/carousel.js",
126
        "vendor/*.js",
127
        "**/*.js"
128
      ]))
129
      .pipe($.concat('scripts.min.js'))
130
      .pipe($.uglify())
131
      .pipe(gulp.dest('../../../public/default/themes/bootstrap/js'));
132
133
});
134